Attribute VB_Name = "UtilDbfs"
Public Sub OrdenarSolicitud(dc As Control)
  uc_Premium.rdoQueries("sp_Com_Trae_Solicitud").rdoParameters(1) = gbCodEmpresa$
  uc_Premium.rdoQueries("sp_Com_Trae_Solicitud").rdoParameters(2) = gbAno$
  uc_Premium.rdoQueries("sp_Com_Trae_Solicitud").rdoParameters(3) = "Co05Tipo"
  uc_Premium.rdoQueries("sp_Com_Trae_Solicitud").rdoParameters(4) = "Co05Codigo Asc"
  Set dc.Recordset = uc_Premium.rdoQueries("sp_Com_Trae_Solicitud").OpenRecordset(rdOpenStatic)
  dc.Refresh
End Sub
Public Sub RefrescaRemoteDataControl(dc As Control, tb As Control, cMensaje$)

    ' Coloco el Puntero en Espera
    Call PunteroRelojDeArena
    
    dc.Recordset.Requery
    dc.Refresh
    If dc.Recordset.RecordCount > 0 Then
        dc.Recordset.MoveLast: dc.Recordset.MoveFirst
        dc.Caption = "Total: " & Trim$(dc.Recordset.RecordCount) & " " & cMensaje$
    Else
        dc.Caption = "Total: 0" & " " & cMensaje$
    End If
    
    ' Coloco el Puntero Normal
    Call PunteroNormal

End Sub
Public Sub CreaTablasSistema(cRuta$, cBD$, cEjercicio$)

    Dim db As Database
    
    Call PunteroRelojDeArena
    
    ' Abro la BD de la Empresa
    If gbTipoBD$ = "SQL" Then
        Set db = DBEngine.Workspaces(0).OpenDatabase("", False, False, "odbc;dsn=" & cBD$ & ";uid=sa;pwd=;logintimeout=300;database=" & cBD$)
    ElseIf gbTipoBD$ = "ACCESS" Then
        Set db = DBEngine.Workspaces(0).CreateDatabase(cRuta$ & cBD$, dbLangGeneral)
    End If
    
    ' Si se esta utilizando SQL
    If gbTipoBD$ = "SQL" Then
    
        ' Tabla Saldos de Ajuste por Inflacion
        cSql$ = "CREATE TABLE dbo.ccacta (" & _
                "ccm01ano varchar (4) NOT NULL ," & _
                "ccm01cta varchar (15) NOT NULL ,"
        For i% = 1 To 2
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_ccacta" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "d", "h") & StrZero(j%, 2) & _
                                "_" & Trim$((16 * (i% - 1)) + (j% + 1)) & "__20 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_ccacta_1__13 PRIMARY KEY  CLUSTERED (ccm01ano,ccm01cta))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Ajuste de Cuentas
        cSql$ = "CREATE TABLE dbo.ccdaju" & cEjercicio$ & " (" & _
                "ccm03tip varchar (1) NOT NULL ," & _
                "ccm03cod varchar (5) NOT NULL ," & _
                "ccm03ctadet varchar (15) NOT NULL ," & _
                "ccm03mes varchar (2) NOT NULL ,"
        For i% = 1 To 2
            nCont% = Choose(i%, 15, 2)
            For j% = 0 To 12
                cSql$ = cSql$ & "ccm03" & Choose(i%, "v", "f") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_ccdaju" & cEjercicio$ & _
                                "_ccm03" & Choose(i%, "v", "f") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__16 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK___1__16 PRIMARY KEY  CLUSTERED (ccm03tip, ccm03cod, ccm03ctadet, ccm03mes))"
        db.Execute cSql$, dbSQLPassThrough
        
        ' Tabla Saldos por Centros de Costo
        cSql$ = "CREATE TABLE dbo.ccdcco" & cEjercicio$ & " (" & _
                "ccm01cc varchar (12) NOT NULL ," & _
                "ccm01cta varchar (15) NOT NULL ,"
        For i% = 1 To 4
            nCont% = Choose(i%, 33, 49, 17, 1)
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_ccdcco" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__20 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_ccdcco" & cEjercicio$ & "_1__13 PRIMARY KEY  CLUSTERED (ccm01cc, ccm01cta))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Saldos por Centros de Directorio
        cSql$ = "CREATE TABLE dbo.ccdcdi" & cEjercicio$ & " (" & _
                "ccm01cd varchar (6) NOT NULL ,"
        For i% = 1 To 4
            nCont% = Choose(i%, 34, 50, 18, 2)
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_ccdcdi" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__17 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_ccdcdi" & cEjercicio$ & "_1__17 PRIMARY KEY  CLUSTERED (ccm01cd))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Saldos por Centros de Gestion
        cSql$ = "CREATE TABLE dbo.ccdcge" & cEjercicio$ & " (" & _
                "ccm01cg varchar (6) NOT NULL ,"
        For i% = 1 To 4
            nCont% = Choose(i%, 34, 50, 18, 2)
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_ccdcge" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__17 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_ccdcge" & cEjercicio$ & "_1__17 PRIMARY KEY  CLUSTERED (ccm01cg))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Saldos por Cuentas
        cSql$ = "CREATE TABLE dbo.ccdcta" & cEjercicio$ & " (" & _
                "ccm01cta varchar (15) NOT NULL ,"
        For i% = 1 To 4
            nCont% = Choose(i%, 33, 49, 17, 1)
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_ccdcta" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__20 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_ccdcta" & cEjercicio$ & "_1__13 PRIMARY KEY  CLUSTERED (ccm01cta))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Presupuestos por Centros de Costos
        cSql$ = "CREATE TABLE dbo.precco" & cEjercicio$ & " (" & _
                "ccm01cc varchar (12) NOT NULL ,"
        For i% = 1 To 2
            nCont% = Choose(i%, 2, 18)
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_precco" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__18 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_precco" & cEjercicio$ & "_1__18 PRIMARY KEY  CLUSTERED (ccm01cc))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Presupuestos por Centros de Directorio
        cSql$ = "CREATE TABLE dbo.precdi" & cEjercicio$ & " (" & _
                "ccm01cd varchar (6) NOT NULL ,"
        For i% = 1 To 2
            nCont% = Choose(i%, 2, 18)
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_precdi" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__17 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_precdi" & cEjercicio$ & "_1__17 PRIMARY KEY  CLUSTERED (ccm01cd))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Presupuestos por Centros de Gestion
        cSql$ = "CREATE TABLE dbo.precge" & cEjercicio$ & " (" & _
                "ccm01cg varchar (6) NOT NULL ,"
        For i% = 1 To 2
            nCont% = Choose(i%, 2, 18)
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_precge" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__17 DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_precge" & cEjercicio$ & "_1__17 PRIMARY KEY  CLUSTERED (ccm01cg))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Presupuestos por Cuentas
        cSql$ = "CREATE TABLE dbo.precta" & cEjercicio$ & " (" & _
                "ccm01cta varchar (15) NOT NULL ,"
        For i% = 1 To 2
            nCont% = Choose(i%, 1, 1)
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & _
                                " float NULL CONSTRAINT DF_precta" & cEjercicio$ & _
                                "_ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & _
                                "_" & Trim$(nCont% + j%) & "__" & Choose(i%, "20", "16") & " DEFAULT (0),"
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT PK_precta" & cEjercicio$ & "_1__13 PRIMARY KEY  CLUSTERED (ccm01cta))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Cabecera de Vouchers
        cSql$ = "CREATE TABLE dbo.ccc" & cEjercicio$ & " (" & _
                "ccc01mes varchar (2) NOT NULL ," & _
                "ccc01subd varchar (2) NOT NULL ," & _
                "ccc01numer varchar (5) NOT NULL ," & _
                "ccc01fecha datetime NULL ," & _
                "ccc01deta varchar (80) NULL ," & _
                "ccc01flag bit NOT NULL ," & _
                "ccc01astip varchar (5) NULL ," & _
                "ccc01trans varchar (1) NULL ," & _
                "CONSTRAINT PK_ccc" & cEjercicio$ & "_1__13 PRIMARY KEY  CLUSTERED (ccc01mes, ccc01subd, ccc01numer))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Detalle de Vouchers
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE dbo.ccd" & cEjercicio$ & " ("
        cSql$ = cSql$ & "ccd01mes varchar (2) NOT NULL ,"
        cSql$ = cSql$ & "ccd01subd varchar (2) NOT NULL ,"
        cSql$ = cSql$ & "ccd01numer varchar (5) NOT NULL ,"
        cSql$ = cSql$ & "ccd01ord float NOT NULL ,"
        cSql$ = cSql$ & "ccd01cta varchar (15) NULL ,"
        cSql$ = cSql$ & "ccd01deb float NULL CONSTRAINT DF_ccd" & cEjercicio$ & "_ccd01deb_3__14 DEFAULT (0),"
        cSql$ = cSql$ & "ccd01hab float NULL CONSTRAINT DF_ccd" & cEjercicio$ & "_ccd01hab_4__14 DEFAULT (0),"
        cSql$ = cSql$ & "ccd01con varchar (80) NULL ,"
        cSql$ = cSql$ & "ccd01tipdoc varchar (2) NULL ,"
        cSql$ = cSql$ & "ccd01ndoc varchar (15) NULL ,"
        cSql$ = cSql$ & "ccd01fedoc datetime NULL ,"
        cSql$ = cSql$ & "ccd01feven datetime NULL ,"
        cSql$ = cSql$ & "ccd01ana varchar (2) NULL ,"
        cSql$ = cSql$ & "ccd01cod varchar (8) NULL ,"
        cSql$ = cSql$ & "ccd01dn varchar (1) NULL ,"
        cSql$ = cSql$ & "ccd01tc float NULL CONSTRAINT DF_ccd" & cEjercicio$ & "_ccd01tc_5__14 DEFAULT (1),"
        cSql$ = cSql$ & "ccd01afin varchar (1) NULL ,"
        cSql$ = cSql$ & "ccd01cc varchar (12) NULL ,"
        cSql$ = cSql$ & "ccd01cg varchar (6) NULL ,"
        cSql$ = cSql$ & "ccd01fevou datetime NULL ,"
        cSql$ = cSql$ & "ccd01ama varchar (1) NULL ,"
        cSql$ = cSql$ & "ccd01astip varchar (5) NULL ,"
        cSql$ = cSql$ & "ccd01val varchar (25) NULL ,"
        cSql$ = cSql$ & "ccd01cd varchar (6) NULL ,"
        cSql$ = cSql$ & "ccd01car float NULL CONSTRAINT DF_ccd" & cEjercicio$ & "_ccd01car_2__14 DEFAULT (0),"
        cSql$ = cSql$ & "ccd01abo float NULL CONSTRAINT DF_ccd" & cEjercicio$ & "_ccd01abo_1__14 DEFAULT (0),"
        cSql$ = cSql$ & "ccd01trans varchar (1) NULL ,"
        cSql$ = cSql$ & "CONSTRAINT PK_ccd" & cEjercicio$ & "_1__13 PRIMARY KEY  CLUSTERED (ccd01mes, ccd01subd, ccd01numer, ccd01ord))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Referencias por Detalle de Voucher
        cSql$ = "CREATE TABLE dbo.ccr" & cEjercicio$ & " (" & _
                "ccr01mes varchar (2) NOT NULL ," & _
                "ccr01subd varchar (2) NOT NULL ," & _
                "ccr01numer varchar (5) NOT NULL ," & _
                "ccr01orddet smallint NOT NULL ," & _
                "ccr01ordref smallint NOT NULL ," & _
                "ccr01ref varchar (3) NULL ," & _
                "ccr01valor varchar (30) NULL ," & _
                "ccr01astip varchar (5) NULL ," & _
                "CONSTRAINT PK_ccr" & cEjercicio$ & "_1__13 PRIMARY KEY  CLUSTERED (ccr01mes, ccr01subd, ccr01numer, ccr01orddet, ccr01ordref))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Rangos de Cuentas
        cSql$ = "CREATE TABLE dbo.ccb01ran (" & _
                "ccb01cod varchar (3) NOT NULL ," & _
                "ccb01des varchar (25) NULL ," & _
                "ccb01inicio varchar (15) NULL ," & _
                "ccb01final varchar (15) NULL ," & _
                "CONSTRAINT PK_Ccb01Ran_1__13 PRIMARY KEY  CLUSTERED (ccb01cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Centros de Costos
        cSql$ = "CREATE TABLE dbo.ccb02cc (" & _
                "ccb02cod varchar (12) NOT NULL ," & _
                "ccb02des varchar (50) NULL ," & _
                "ccb02mov varchar (1) NULL ," & _
                "CONSTRAINT PK_ccb02cc_1__20 PRIMARY KEY  CLUSTERED (ccb02cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Centros de Directorio
        cSql$ = "CREATE TABLE dbo.ccb02cd (" & _
                "ccb02cod varchar (6) NOT NULL ," & _
                "ccb02des varchar (50) NULL ," & _
                "ccb02mov varchar (1) NULL ," & _
                "CONSTRAINT PK_ccb02cd_1__25 PRIMARY KEY  CLUSTERED (ccb02cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Centros de Gestion
        cSql$ = "CREATE TABLE dbo.ccb02cg (" & _
                "ccb02cod varchar (6) NOT NULL ," & _
                "ccb02des varchar (50) NULL ," & _
                "ccb02tip varchar (1) NULL ," & _
                "ccb02cd varchar (6) NULL ," & _
                "ccb02mov varchar (1) NULL ," & _
                "CONSTRAINT PK___1__25 PRIMARY KEY  CLUSTERED (ccb02cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Cuentas por Libro Auxiliar
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE dbo.ccb02ctalib ("
        cSql$ = cSql$ & "ccb02lib varchar (2) NOT NULL ,"
        cSql$ = cSql$ & "ccb02ord smallint NOT NULL ,"
        cSql$ = cSql$ & "ccb02cta1 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta2 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta3 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta4 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta5 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta6 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta7 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta8 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta9 varchar (15) NULL ,"
        cSql$ = cSql$ & "ccb02cta10 varchar (15) NULL ,"
        cSql$ = cSql$ & "CONSTRAINT PK_ccb02ctalib_1__13 PRIMARY KEY  CLUSTERED (ccb02lib, ccb02ord))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Libros Auxiliares
        cSql$ = "CREATE TABLE dbo.ccb02subd (" & _
                "ccb02cod varchar (2) NOT NULL ," & _
                "ccb02des varchar (30) NULL ," & _
                "ccb02asig1 varchar (2) NULL ," & _
                "ccb02asig2 varchar (2) NULL ," & _
                "ccb02asig3 varchar (2) NULL ," & _
                "ccb02tip varchar (1) NULL ," & _
                "CONSTRAINT PK_ccb02subd_1__13 PRIMARY KEY  CLUSTERED (ccb02cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Tipos de Documentos
        cSql$ = "CREATE TABLE dbo.ccb02tipd (" & _
                "ccb02cod varchar (2) NOT NULL ," & _
                "ccb02des varchar (30) NULL ," & _
                "ccb02sig varchar (1) NULL ," & _
                "ccb02doc varchar (1) NULL ," & _
                "ccb02ref varchar (3) NULL ," & _
                "CONSTRAINT PK_ccb02tipd_1__13 PRIMARY KEY  CLUSTERED (ccb02cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Periodos
        cSql$ = "CREATE TABLE dbo.ccb03per (" & _
                "ccb03cod varchar (6) NOT NULL ," & _
                "ccb03des varchar (15) NULL ," & _
                "ccb03proc bit NOT NULL ," & _
                "ccb03tc float NULL CONSTRAINT DF_ccb03per_ccb03tc_15__20 DEFAULT (0)," & _
                "ccb03ipm float NULL CONSTRAINT DF_ccb03per_ccb03ipm_14__20 DEFAULT (0),"
        For i% = 0 To 12
            cSql$ = cSql$ & "ccb03fa" & StrZero(i%, 2) & " float NULL" & _
                            " CONSTRAINT DF_ccb03per_ccb03fa" & StrZero(i%, 2) & _
                            "_" & Trim$(i% + 1) & "__20 DEFAULT (0),"
        Next i%
        cSql$ = cSql$ & "ccb03cms float NULL CONSTRAINT DF_ccb03per_ccb03cms_2__15 DEFAULT (0),"
        cSql$ = cSql$ & "ccb03cmd float NULL CONSTRAINT DF_ccb03per_ccb03cmd_1__15 DEFAULT (0),"
        cSql$ = cSql$ & "CONSTRAINT PK_ccb03per_1__13 PRIMARY KEY  CLUSTERED (ccb03cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Referencias
        cSql$ = "CREATE TABLE dbo.ccb04ref (" & _
                "ccb04cod varchar (3) NOT NULL ," & _
                "ccb04des varchar (25) NULL ," & _
                "CONSTRAINT PK_ccb04ref_1__13 PRIMARY KEY  CLUSTERED (ccb04cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Documentos Pendientes
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE dbo.ccb13dpe ("
        cSql$ = cSql$ & "ccb13cta varchar (15) NOT NULL ,"
        cSql$ = cSql$ & "ccb13ana varchar (2) NOT NULL ,"
        cSql$ = cSql$ & "ccb13cod varchar (8) NOT NULL ,"
        cSql$ = cSql$ & "ccb13tipdoc varchar (2) NOT NULL ,"
        cSql$ = cSql$ & "ccb13ndoc varchar (15) NOT NULL ,"
        cSql$ = cSql$ & "ccb13fedoc datetime NULL ,"
        cSql$ = cSql$ & "ccb13dn varchar (1) NULL ,"
        cSql$ = cSql$ & "ccb13deb float NULL CONSTRAINT DF_ccb13dpe_ccb13deb_4__14 DEFAULT (0),"
        cSql$ = cSql$ & "ccb13hab float NULL CONSTRAINT DF_ccb13dpe_ccb13hab_5__14 DEFAULT (0),"
        cSql$ = cSql$ & "ccb13car float NULL CONSTRAINT DF_ccb13dpe_ccb13car_3__14 DEFAULT (0),"
        cSql$ = cSql$ & "ccb13abo float NULL CONSTRAINT DF_ccb13dpe_ccb13abo_2__14 DEFAULT (0),"
        cSql$ = cSql$ & "CONSTRAINT PK_ccb13dpe_1__14 PRIMARY KEY  CLUSTERED (ccb13cta, ccb13ana, ccb13cod, ccb13tipdoc, ccb13ndoc))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Validacion de Importacion
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE dbo.ccb14val ("
        cSql$ = cSql$ & "pervou varchar (6) NULL ,"
        cSql$ = cSql$ & "convou varchar (2) NULL ,"
        cSql$ = cSql$ & "dfuvou varchar (2) NULL ,"
        cSql$ = cSql$ & "nduvou varchar (5) NULL ,"
        cSql$ = cSql$ & "secvou float NULL CONSTRAINT DF_ccb14val_secvou_4__29 DEFAULT (0),"
        cSql$ = cSql$ & "fecvou datetime NULL ,"
        cSql$ = cSql$ & "asivou varchar (2) NULL ,"
        cSql$ = cSql$ & "ctavou varchar (15) NULL ,"
        cSql$ = cSql$ & "cecvou varchar (12) NULL ,"
        cSql$ = cSql$ & "ctevou varchar (8) NULL ,"
        cSql$ = cSql$ & "ttevou varchar (2) NULL ,"
        cSql$ = cSql$ & "dbavou varchar (2) NULL ,"
        cSql$ = cSql$ & "nbavou varchar (12) NULL ,"
        cSql$ = cSql$ & "fvevou datetime NULL ,"
        cSql$ = cSql$ & "debvou float NULL CONSTRAINT DF_ccb14val_debvou_1__29 DEFAULT (0),"
        cSql$ = cSql$ & "habvou float NULL CONSTRAINT DF_ccb14val_habvou_2__29 DEFAULT (0),"
        cSql$ = cSql$ & "monvou varchar (1) NULL ,"
        cSql$ = cSql$ & "tcavou float NULL ,"
        cSql$ = cSql$ & "vomvou float NULL CONSTRAINT DF_ccb14val_vomvou_5__29 DEFAULT (0),"
        cSql$ = cSql$ & "cgevou varchar (6) NULL ,"
        cSql$ = cSql$ & "ntevou varchar (50) NULL ,"
        cSql$ = cSql$ & "glovou varchar (80) NULL ,"
        cSql$ = cSql$ & "des_trans varchar (50) NULL ,"
        cSql$ = cSql$ & "per_trans varchar (6) NULL ,"
        cSql$ = cSql$ & "reg_trans float NULL CONSTRAINT DF_ccb14val_reg_trans_3__29 DEFAULT (0))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Archivos a Importar
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE dbo.ccb15imp ("
        cSql$ = cSql$ & "ccb15cod smallint NOT NULL ,"
        cSql$ = cSql$ & "ccb15nom varchar (12) NULL ,"
        cSql$ = cSql$ & "ccb15des varchar (50) NULL ,"
        cSql$ = cSql$ & "ccb15per varchar (6) NULL ,"
        cSql$ = cSql$ & "ccb15fec datetime NULL ,"
        cSql$ = cSql$ & "ccb15trf varchar (1) NULL ,"
        cSql$ = cSql$ & "ccb15perimp varchar (6) NULL ,"
        cSql$ = cSql$ & "ccb15voucre1 varchar (250) NULL ,"
        cSql$ = cSql$ & "ccb15voucre2 varchar (250) NULL ,"
        cSql$ = cSql$ & "ccb15numreg float NULL CONSTRAINT DF_ccb15imp_ccb15numreg_2__10 DEFAULT (0),"
        cSql$ = cSql$ & "CONSTRAINT PK_ccb15imp_1__10 PRIMARY KEY  CLUSTERED (ccb15cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Tipos de Analisis
        cSql$ = "CREATE TABLE dbo.ccb17ana (" & _
                "ccb17cdgo varchar (2) NOT NULL ," & _
                "ccb17desc varchar (30) NULL ," & _
                "CONSTRAINT PK_ccb17ana_1__13 PRIMARY KEY  CLUSTERED (ccb17cdgo))"
        db.Execute cSql$, dbSQLPassThrough
     
        ' Tabla Cabecera de Asientos Tipo
        cSql$ = "CREATE TABLE dbo.ccc03astip (" & _
                "ccc03cod varchar (5) NOT NULL ," & _
                "ccc03des varchar (80) NULL ," & _
                "ccc03lib varchar (2) NULL ," & _
                "CONSTRAINT PK_ccc03astip_1__13 PRIMARY KEY  CLUSTERED (ccc03cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Detalle de Asientos Tipo
        cSql$ = "CREATE TABLE dbo.ccd03astip (" & _
                "ccd03cod varchar (5) NOT NULL ," & _
                "ccd03ord smallint NOT NULL ," & _
                "ccd03cta varchar (15) NULL ," & _
                "ccd03afin varchar (1) NULL ," & _
                "ccd03ca varchar (1) NULL ," & _
                "ccd03req varchar (1) NULL ," & _
                "ccd03mul varchar (1) NULL ," & _
                "ccd03def varchar (15) NULL ," & _
                "CONSTRAINT PK_ccd03astip_1__13 PRIMARY KEY  CLUSTERED (ccd03cod, ccd03ord))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Detalle de Reporte Generado
        cSql$ = "CREATE TABLE dbo.ccd20grp (" & _
                "ccd20cod varchar (6) NOT NULL ," & _
                "ccd20ord smallint NOT NULL ," & _
                "ccd20niv smallint NULL ," & _
                "ccd20cta varchar (15) NULL ," & _
                "ccd20den varchar (60) NULL ," & _
                "ccd20sig varchar (1) NULL ," & _
                "ccd20tip varchar (1) NULL ," & _
                "ccd20imp bit NOT NULL ," & _
                "CONSTRAINT PK_ccd20grp_1__16 PRIMARY KEY  CLUSTERED (ccd20cod, ccd20ord))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Plan de Cuentas
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE dbo.ccm01cta ("
        cSql$ = cSql$ & "ccm01cta varchar (15) NOT NULL ,"
        cSql$ = cSql$ & "ccm01des varchar (60) NULL ,"
        cSql$ = cSql$ & "ccm01dn varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01amd varchar (15) NULL ,"
        cSql$ = cSql$ & "ccm01amh varchar (15) NULL ,"
        cSql$ = cSql$ & "ccm01cla varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01salda varchar (15) NULL ,"
        cSql$ = cSql$ & "ccm01ana varchar (2) NULL ,"
        cSql$ = cSql$ & "ccm01bal varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01p1 float NULL CONSTRAINT DF_ccm01cta_ccm01p1_1__14 DEFAULT (100),"
        cSql$ = cSql$ & "ccm01p2 float NULL CONSTRAINT DF_ccm01cta_ccm01p2_2__14 DEFAULT (100),"
        cSql$ = cSql$ & "ccm01aj varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01axi varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01cc varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01fv varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01cg varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01tc varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01mov varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01rec varchar (1) NULL ,"
        cSql$ = cSql$ & "ccm01flu varchar (1) NULL ,"
        cSql$ = cSql$ & "CONSTRAINT PK_ccm01cta_1__13 PRIMARY KEY  CLUSTERED (ccm01cta))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Cuentas Corrientes
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE dbo.ccm02cta ("
        cSql$ = cSql$ & "ccm02tipana varchar (2) NOT NULL ,"
        cSql$ = cSql$ & "ccm02cod varchar (8) NOT NULL ,"
        cSql$ = cSql$ & "ccm02nom varchar (50) NULL ,"
        cSql$ = cSql$ & "ccm02dir varchar (50) NULL ,"
        cSql$ = cSql$ & "ccm02tel varchar (7) NULL ,"
        cSql$ = cSql$ & "ccm02fec datetime NULL ,"
        cSql$ = cSql$ & "ccm02ruc varchar (8) NULL ,"
        cSql$ = cSql$ & "ccm02ncta varchar (20) NULL ,"
        cSql$ = cSql$ & "ccm02tpag varchar (1) NULL ,"
        cSql$ = cSql$ & "CONSTRAINT PK_ccm02cta1_1__14 PRIMARY KEY  CLUSTERED (ccm02tipana, ccm02cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Cabecera de Reporte Generado
        cSql$ = "CREATE TABLE dbo.ccm20grp (" & _
                "ccm20cod varchar (6) NOT NULL ," & _
                "ccm20des varchar (35) NULL ," & _
                "ccm20tit varchar (80) NULL ," & _
                "ccm20col varchar (20) NULL ," & _
                "CONSTRAINT PK_Ccm20Grp_1__13 PRIMARY KEY  CLUSTERED (ccm20cod))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Estado de Ganancias y Perdidas
        cSql$ = "CREATE TABLE dbo.cct01egp (" & _
                "cct01egp varchar (1) NOT NULL ," & _
                "cct01ord smallint NOT NULL ," & _
                "cct01tip varchar (1) NULL ," & _
                "cct01cta varchar (15) NULL ," & _
                "cct01des varchar (60) NULL ," & _
                "cct01imp bit NOT NULL ," & _
                "cct01exc varchar (50) NULL ," & _
                "CONSTRAINT PK_cct01egp_1__18 PRIMARY KEY  CLUSTERED (cct01egp, cct01ord))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Detalle de Distribucion de Gastos
        cSql$ = "CREATE TABLE dbo.detdistgastos (" & _
                "Codigo varchar (3) NOT NULL ," & _
                "Cuenta varchar (15) NOT NULL ," & _
                "CtaCte varchar (8) NOT NULL ," & _
                "CenCos varchar (12) NOT NULL ," & _
                "CenGes varchar (6) NOT NULL ," & _
                "Porcentaje float NULL CONSTRAINT DF_DetDistGas_Porcentaje_1__20 DEFAULT (0)," & _
                "CONSTRAINT PK_DetDistGastos_1__13 PRIMARY KEY  CLUSTERED (Codigo, Cuenta, CtaCte, CenCos, CenGes))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Cabecera de Distribucion de Gastos
        cSql$ = "CREATE TABLE dbo.distgastos (" & _
                "Codigo varchar (3) NOT NULL ," & _
                "Descripcion varchar (30) NULL ," & _
                "CONSTRAINT PK_distgastos_1__22 PRIMARY KEY  CLUSTERED (Codigo))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Formula de Ratios
        cSql$ = "CREATE TABLE dbo.formratio (" & _
                "Codigo varchar (3) NOT NULL ," & _
                "Correlativo smallint NOT NULL ," & _
                "Variable varchar (20) NULL ," & _
                "CONSTRAINT PK_FormRatio_1__13 PRIMARY KEY  CLUSTERED (Codigo, Correlativo))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Ratios
        cSql$ = "CREATE TABLE dbo.ratios (" & _
                "Codigo varchar (3) NOT NULL ," & _
                "Descripcion varchar (30) NULL ," & _
                "CONSTRAINT PK_Ratios_1__13 PRIMARY KEY  CLUSTERED (Codigo))"
        db.Execute cSql$, dbSQLPassThrough
    
        ' Tabla Resultados por Ratios
        cSql$ = "CREATE TABLE dbo.resultratios (" & _
                "Periodo varchar (6) NOT NULL ," & _
                "Codigo varchar (3) NOT NULL ," & _
                "Monto float NULL CONSTRAINT DF_ResultRati_Monto_1__20 DEFAULT (0)," & _
                "CONSTRAINT PK_ResultRatios_1__13 PRIMARY KEY  CLUSTERED (Periodo, Codigo))"
        db.Execute cSql$, dbSQLPassThrough
        
    Else
    
        ' Tabla Saldos de Ajuste por Inflacion
        cSql$ = "CREATE TABLE ccacta" & cEjercicio$ & " (ccm01cta TEXT (15) CONSTRAINT [Primary Key] PRIMARY KEY, "
        For i% = 1 To 2
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = Left$(cSql$, Len(cSql$) - 2) & ")"
        db.Execute cSql$
    
        ' Tabla Ajuste de Cuentas
        cSql$ = "CREATE TABLE ccdaju" & cEjercicio$ & " (ccm03tip TEXT (1), ccm03cod TEXT (5), ccm03ctadet TEXT (15), ccm03mes TEXT (2), "
        For i% = 1 To 2
            For j% = 0 To 12
                cSql$ = cSql$ & "ccm01" & Choose(i%, "v", "f") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT [Primary Key] PRIMARY KEY (ccm03tip, ccm03cod, ccm03ctadet, ccm03mes))"
        db.Execute cSql$
        
        ' Tabla Saldos por Centros de Costo
        cSql$ = "CREATE TABLE ccdcco" & cEjercicio$ & " (ccm01cc TEXT (12), ccm01cta TEXT (15), "
        For i% = 1 To 4
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = cSql$ & "CONSTRAINT [Primary Key] PRIMARY KEY (ccm01cc, ccm01cta))"
        db.Execute cSql$
    
        ' Tabla Saldos por Centros de Directorio
        cSql$ = "CREATE TABLE ccdcdi" & cEjercicio$ & " (ccm01cd TEXT (6) CONSTRAINT [Primary Key] PRIMARY KEY, "
        For i% = 1 To 4
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = Left$(cSql$, Len(cSql$) - 2) & ")"
        db.Execute cSql$
    
        ' Tabla Saldos por Centros de Gestion
        cSql$ = "CREATE TABLE ccdcge" & cEjercicio$ & " (ccm01cg TEXT (6) CONSTRAINT [Primary Key] PRIMARY KEY, "
        For i% = 1 To 4
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = Left$(cSql$, Len(cSql$) - 2) & ")"
        db.Execute cSql$
    
        ' Tabla Saldos por Cuentas
        cSql$ = "CREATE TABLE ccdcta" & cEjercicio$ & " (ccm01cta TEXT (15) CONSTRAINT [Primary Key] PRIMARY KEY, "
        For i% = 1 To 4
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "d", "h", "c", "a") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = Left$(cSql$, Len(cSql$) - 2) & ")"
        db.Execute cSql$
    
        ' Tabla Presupuestos por Centros de Costos
        cSql$ = "CREATE TABLE precco" & cEjercicio$ & " (ccm01cc TEXT (12) CONSTRAINT [Primary Key] PRIMARY KEY, "
        For i% = 1 To 2
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = Left$(cSql$, Len(cSql$) - 2) & ")"
        db.Execute cSql$
    
        ' Tabla Presupuestos por Centros de Directorio
        cSql$ = "CREATE TABLE precdi" & cEjercicio$ & " (ccm01cd TEXT (6) CONSTRAINT [Primary Key] PRIMARY KEY, "
        For i% = 1 To 2
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = Left$(cSql$, Len(cSql$) - 2) & ")"
        db.Execute cSql$
    
        ' Tabla Presupuestos por Centros de Gestion
        cSql$ = "CREATE TABLE precge" & cEjercicio$ & " (ccm01cg TEXT (6) CONSTRAINT [Primary Key] PRIMARY KEY, "
        For i% = 1 To 2
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = Left$(cSql$, Len(cSql$) - 2) & ")"
        db.Execute cSql$
    
        ' Tabla Presupuestos por Cuentas
        cSql$ = "CREATE TABLE precta" & cEjercicio$ & " (ccm01cta TEXT (15) CONSTRAINT [Primary Key] PRIMARY KEY, "
        For i% = 1 To 2
            For j% = 0 To 15
                cSql$ = cSql$ & "ccm01" & Choose(i%, "p", "t") & StrZero(j%, 2) & " DOUBLE, "
            Next j%
        Next i%
        cSql$ = Left$(cSql$, Len(cSql$) - 2) & ")"
        db.Execute cSql$
    
        ' Tabla Cabecera de Vouchers
        cSql$ = "CREATE TABLE ccc" & cEjercicio$ & " (" & _
                "ccc01mes TEXT (2), " & _
                "ccc01subd TEXT (2), " & _
                "ccc01numer TEXT (5), " & _
                "ccc01fecha DATETIME, " & _
                "ccc01deta TEXT (80), " & _
                "ccc01flag BIT, " & _
                "ccc01astip TEXT (5), " & _
                "ccc01trans TEXT (1), " & _
                "CONSTRAINT [Primary Key] PRIMARY KEY (ccc01mes, ccc01subd, ccc01numer))"
        db.Execute cSql$
    
        ' Tabla Detalle de Vouchers
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE ccd" & cEjercicio$ & " ("
        cSql$ = cSql$ & "ccd01mes TEXT (2), "
        cSql$ = cSql$ & "ccd01subd TEXT (2), "
        cSql$ = cSql$ & "ccd01numer TEXT (5), "
        cSql$ = cSql$ & "ccd01ord DOUBLE, "
        cSql$ = cSql$ & "ccd01cta TEXT (15), "
        cSql$ = cSql$ & "ccd01deb DOUBLE, "
        cSql$ = cSql$ & "ccd01hab DOUBLE, "
        cSql$ = cSql$ & "ccd01con TEXT (80), "
        cSql$ = cSql$ & "ccd01tipdoc TEXT (2), "
        cSql$ = cSql$ & "ccd01ndoc TEXT (15), "
        cSql$ = cSql$ & "ccd01fedoc DATETIME, "
        cSql$ = cSql$ & "ccd01feven DATETIME, "
        cSql$ = cSql$ & "ccd01ana TEXT (2), "
        cSql$ = cSql$ & "ccd01cod TEXT (8), "
        cSql$ = cSql$ & "ccd01dn TEXT (1), "
        cSql$ = cSql$ & "ccd01tc DOUBLE, "
        cSql$ = cSql$ & "ccd01afin TEXT (1), "
        cSql$ = cSql$ & "ccd01cc TEXT (12), "
        cSql$ = cSql$ & "ccd01cg TEXT (6), "
        cSql$ = cSql$ & "ccd01fevou DATETIME, "
        cSql$ = cSql$ & "ccd01ama TEXT (1), "
        cSql$ = cSql$ & "ccd01astip TEXT (5), "
        cSql$ = cSql$ & "ccd01val TEXT (25), "
        cSql$ = cSql$ & "ccd01cd TEXT (6), "
        cSql$ = cSql$ & "ccd01car DOUBLE, "
        cSql$ = cSql$ & "ccd01abo DOUBLE, "
        cSql$ = cSql$ & "ccd01trans TEXT (1), "
        cSql$ = cSql$ & "CONSTRAINT [Primary Key] PRIMARY KEY (ccd01mes, ccd01subd, ccd01numer, ccd01ord))"
        db.Execute cSql$
    
        ' Tabla Referencias por Detalle de Voucher
        cSql$ = "CREATE TABLE ccr" & cEjercicio$ & " (" & _
                "ccr01mes TEXT (2), " & _
                "ccr01subd TEXT (2), " & _
                "ccr01numer TEXT (5), " & _
                "ccr01orddet DOUBLE, " & _
                "ccr01ordref DOUBLE, " & _
                "ccr01ref TEXT (3), " & _
                "ccr01valor TEXT (30), " & _
                "ccr01astip TEXT (5), " & _
                "CONSTRAINT [Primary Key] PRIMARY KEY (ccr01mes, ccr01subd, ccr01numer, ccr01orddet, ccr01ordref))"
        db.Execute cSql$
    
        ' Tabla Rangos de Cuentas
        cSql$ = "CREATE TABLE ccb01ran (" & _
                "ccb01cod TEXT (3) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb01des TEXT (25), " & _
                "ccb01inicio TEXT (15), " & _
                "ccb01final TEXT (15))"
        db.Execute cSql$
    
        ' Tabla Centros de Costos
        cSql$ = "CREATE TABLE ccb02cc (" & _
                "ccb02cod TEXT (12) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb02des TEXT (50), " & _
                "ccb02mov TEXT (1))"
        db.Execute cSql$
    
        ' Tabla Centros de Directorio
        cSql$ = "CREATE TABLE ccb02cd (" & _
                "ccb02cod TEXT (6) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb02des TEXT (50), " & _
                "ccb02mov TEXT (1))"
        db.Execute cSql$
    
        ' Tabla Centros de Gestion
        cSql$ = "CREATE TABLE ccb02cg (" & _
                "ccb02cod TEXT (6) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb02des TEXT (50), " & _
                "ccb02tip TEXT (1), " & _
                "ccb02cd TEXT (6), " & _
                "ccb02mov TEXT (1))"
        db.Execute cSql$
    
        ' Tabla Cuentas por Libro Auxiliar
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE ccb02ctalib ("
        cSql$ = cSql$ & "ccb02lib TEXT (2), "
        cSql$ = cSql$ & "ccb02ord SINGLE, "
        cSql$ = cSql$ & "ccb02cta1 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta2 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta3 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta4 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta5 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta6 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta7 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta8 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta9 TEXT (15), "
        cSql$ = cSql$ & "ccb02cta10 TEXT (15), "
        cSql$ = cSql$ & "CONSTRAINT [Primary Key] PRIMARY KEY (ccb02lib, ccb02ord))"
        db.Execute cSql$
    
        ' Tabla Libros Auxiliares
        cSql$ = "CREATE TABLE ccb02subd (" & _
                "ccb02cod TEXT (2) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb02des TEXT (30), " & _
                "ccb02asig1 TEXT (2), " & _
                "ccb02asig2 TEXT (2), " & _
                "ccb02asig3 TEXT (2), " & _
                "ccb02tip TEXT (1))"
        db.Execute cSql$
    
        ' Tabla Tipos de Documentos
        cSql$ = "CREATE TABLE ccb02tipd (" & _
                "ccb02cod TEXT (2) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb02des TEXT (30), " & _
                "ccb02sig TEXT (1), " & _
                "ccb02doc TEXT (1), " & _
                "ccb02ref TEXT (3))"
        db.Execute cSql$
    
        ' Tabla Periodos
        cSql$ = "CREATE TABLE ccb03per (" & _
                "ccb03cod TEXT (6) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb03des TEXT (15), " & _
                "ccb03proc BIT, " & _
                "ccb03tc DOUBLE, " & _
                "ccb03ipm DOUBLE, "
        For i% = 0 To 12
            cSql$ = cSql$ & "ccb03fa" & StrZero(i%, 2) & " DOUBLE, "
        Next i%
        cSql$ = cSql$ & "ccb03cms DOUBLE, "
        cSql$ = cSql$ & "ccb03cmd DOUBLE)"
        db.Execute cSql$
    
        ' Tabla Referencias
        cSql$ = "CREATE TABLE ccb04ref (" & _
                "ccb04cod TEXT (3) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb04des TEXT (25))"
        db.Execute cSql$
    
        ' Tabla Documentos Pendientes
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE ccb13dpe ("
        cSql$ = cSql$ & "ccb13cta TEXT (15), "
        cSql$ = cSql$ & "ccb13ana TEXT (2), "
        cSql$ = cSql$ & "ccb13cod TEXT (8), "
        cSql$ = cSql$ & "ccb13tipdoc TEXT (2), "
        cSql$ = cSql$ & "ccb13ndoc TEXT (15), "
        cSql$ = cSql$ & "ccb13fedoc DATETIME, "
        cSql$ = cSql$ & "ccb13dn TEXT (1), "
        cSql$ = cSql$ & "ccb13deb DOUBLE, "
        cSql$ = cSql$ & "ccb13hab DOUBLE, "
        cSql$ = cSql$ & "ccb13car DOUBLE, "
        cSql$ = cSql$ & "ccb13abo DOUBLE, "
        cSql$ = cSql$ & "CONSTRAINT [Primary Key] PRIMARY KEY (ccb13cta, ccb13ana, ccb13cod, ccb13tipdoc, ccb13ndoc))"
        db.Execute cSql$
    
        ' Tabla Validacion de Importacion
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE ccb14val ("
        cSql$ = cSql$ & "pervou TEXT (6), "
        cSql$ = cSql$ & "convou TEXT (2), "
        cSql$ = cSql$ & "dfuvou TEXT (2), "
        cSql$ = cSql$ & "nduvou TEXT (5), "
        cSql$ = cSql$ & "secvou DOUBLE, "
        cSql$ = cSql$ & "fecvou DATETIME, "
        cSql$ = cSql$ & "asivou TEXT (2), "
        cSql$ = cSql$ & "ctavou TEXT (15), "
        cSql$ = cSql$ & "cecvou TEXT (12), "
        cSql$ = cSql$ & "ctevou TEXT (8), "
        cSql$ = cSql$ & "ttevou TEXT (2), "
        cSql$ = cSql$ & "dbavou TEXT (2), "
        cSql$ = cSql$ & "nbavou TEXT (12), "
        cSql$ = cSql$ & "fvevou DATETIME, "
        cSql$ = cSql$ & "debvou DOUBLE, "
        cSql$ = cSql$ & "habvou DOUBLE, "
        cSql$ = cSql$ & "monvou TEXT (1), "
        cSql$ = cSql$ & "tcavou DOUBLE, "
        cSql$ = cSql$ & "vomvou DOUBLE, "
        cSql$ = cSql$ & "cgevou TEXT (6), "
        cSql$ = cSql$ & "ntevou TEXT (50), "
        cSql$ = cSql$ & "glovou TEXT (80), "
        cSql$ = cSql$ & "des_trans TEXT (50), "
        cSql$ = cSql$ & "per_trans TEXT (6), "
        cSql$ = cSql$ & "reg_trans DOUBLE)"
        db.Execute cSql$
    
        ' Tabla Archivos a Importar
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE ccb15imp ("
        cSql$ = cSql$ & "ccb15cod SINGLE CONSTRAINT [Primary Key] PRIMARY KEY, "
        cSql$ = cSql$ & "ccb15nom TEXT (12), "
        cSql$ = cSql$ & "ccb15des TEXT (50), "
        cSql$ = cSql$ & "ccb15per TEXT (6), "
        cSql$ = cSql$ & "ccb15fec DATETIME, "
        cSql$ = cSql$ & "ccb15trf TEXT (1), "
        cSql$ = cSql$ & "ccb15perimp TEXT (6), "
        cSql$ = cSql$ & "ccb15voucre1 TEXT (250), "
        cSql$ = cSql$ & "ccb15voucre2 TEXT (250), "
        cSql$ = cSql$ & "ccb15numreg DOUBLE)"
        db.Execute cSql$
    
        ' Tabla Tipos de Analisis
        cSql$ = "CREATE TABLE ccb17ana (" & _
                "ccb17cdgo TEXT (2) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccb17desc TEXT (30))"
        db.Execute cSql$
     
        ' Tabla Cabecera de Asientos Tipo
        cSql$ = "CREATE TABLE ccc03astip (" & _
                "ccc03cod TEXT (5) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccc03des TEXT (80), " & _
                "ccc03lib TEXT (2))"
        db.Execute cSql$
    
        ' Tabla Detalle de Asientos Tipo
        cSql$ = "CREATE TABLE ccd03astip (" & _
                "ccd03cod TEXT (5), " & _
                "ccd03ord SINGLE, " & _
                "ccd03cta TEXT (15), " & _
                "ccd03afin TEXT (1), " & _
                "ccd03ca TEXT (1), " & _
                "ccd03req TEXT (1), " & _
                "ccd03mul TEXT (1), " & _
                "ccd03def TEXT (15), " & _
                "CONSTRAINT [Primary Key] PRIMARY KEY (ccd03cod, ccd03ord))"
        db.Execute cSql$
    
        ' Tabla Detalle de Reporte Generado
        cSql$ = "CREATE TABLE ccd20grp (" & _
                "ccd20cod TEXT (6), " & _
                "ccd20ord SINGLE, " & _
                "ccd20niv SINGLE, " & _
                "ccd20cta TEXT (15), " & _
                "ccd20den TEXT (60), " & _
                "ccd20sig TEXT (1), " & _
                "ccd20tip TEXT (1), " & _
                "ccd20imp BIT, " & _
                "CONSTRAINT [Primary Key] PRIMARY KEY (ccd20cod, ccd20ord))"
        db.Execute cSql$
    
        ' Tabla Plan de Cuentas
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE ccm01cta ("
        cSql$ = cSql$ & "ccm01cta TEXT (15) CONSTRAINT [Primary Key] PRIMARY KEY, "
        cSql$ = cSql$ & "ccm01des TEXT (60), "
        cSql$ = cSql$ & "ccm01dn TEXT (1), "
        cSql$ = cSql$ & "ccm01amd TEXT (15), "
        cSql$ = cSql$ & "ccm01amh TEXT (15), "
        cSql$ = cSql$ & "ccm01cla TEXT (1), "
        cSql$ = cSql$ & "ccm01salda TEXT (15), "
        cSql$ = cSql$ & "ccm01ana TEXT (2), "
        cSql$ = cSql$ & "ccm01bal TEXT (1), "
        cSql$ = cSql$ & "ccm01p1 DOUBLE, "
        cSql$ = cSql$ & "ccm01p2 DOUBLE, "
        cSql$ = cSql$ & "ccm01aj TEXT (1), "
        cSql$ = cSql$ & "ccm01axi TEXT (1), "
        cSql$ = cSql$ & "ccm01cc TEXT (1), "
        cSql$ = cSql$ & "ccm01fv TEXT (1), "
        cSql$ = cSql$ & "ccm01cg TEXT (1), "
        cSql$ = cSql$ & "ccm01tc TEXT (1), "
        cSql$ = cSql$ & "ccm01mov TEXT (1), "
        cSql$ = cSql$ & "ccm01rec TEXT (1), "
        cSql$ = cSql$ & "ccm01flu TEXT (1))"
        db.Execute cSql$
    
        ' Tabla Cuentas Corrientes
        cSql$ = ""
        cSql$ = cSql$ & "CREATE TABLE ccm02cta ("
        cSql$ = cSql$ & "ccm02tipana TEXT (2), "
        cSql$ = cSql$ & "ccm02cod TEXT (8), "
        cSql$ = cSql$ & "ccm02nom TEXT (50), "
        cSql$ = cSql$ & "ccm02dir TEXT (50), "
        cSql$ = cSql$ & "ccm02tel TEXT (7), "
        cSql$ = cSql$ & "ccm02fec DATETIME, "
        cSql$ = cSql$ & "ccm02ruc TEXT (8), "
        cSql$ = cSql$ & "ccm02ncta TEXT (20), "
        cSql$ = cSql$ & "ccm02tpag TEXT (1), "
        cSql$ = cSql$ & "CONSTRAINT [Primary Key] PRIMARY KEY (ccm02tipana, ccm02cod))"
        db.Execute cSql$
    
        ' Tabla Cabecera de Reporte Generado
        cSql$ = "CREATE TABLE ccm20grp (" & _
                "ccm20cod TEXT (6) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "ccm20des TEXT (35), " & _
                "ccm20tit TEXT (80), " & _
                "ccm20col TEXT (20))"
        db.Execute cSql$
    
        ' Tabla Estado de Ganancias y Perdidas
        cSql$ = "CREATE TABLE cct01egp (" & _
                "cct01egp TEXT (1), " & _
                "cct01ord SINGLE, " & _
                "cct01tip TEXT (1), " & _
                "cct01cta TEXT (15), " & _
                "cct01des TEXT (60), " & _
                "cct01imp BIT, " & _
                "cct01exc TEXT (50), " & _
                "CONSTRAINT [Primary Key] PRIMARY KEY (cct01egp, cct01ord))"
        db.Execute cSql$
    
        ' Tabla Detalle de Distribucion de Gastos
        cSql$ = "CREATE TABLE detdistgastos (" & _
                "Codigo TEXT (3), " & _
                "Cuenta TEXT (15), " & _
                "CtaCte TEXT (8), " & _
                "CenCos TEXT (12), " & _
                "CenGes TEXT (6), " & _
                "Porcentaje DOUBLE, " & _
                "CONSTRAINT [Primary Key] PRIMARY KEY (Codigo, Cuenta, CtaCte, CenCos, CenGes))"
        db.Execute cSql$
    
        ' Tabla Cabecera de Distribucion de Gastos
        cSql$ = "CREATE TABLE distgastos (" & _
                "Codigo TEXT (3) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "Descripcion TEXT (30))"
        db.Execute cSql$
    
        ' Tabla Formula de Ratios
        cSql$ = "CREATE TABLE formratio (" & _
                "Codigo TEXT (3), " & _
                "Correlativo SINGLE, " & _
                "Variable TEXT (20), " & _
                "CONSTRAINT [Primary Key] PRIMARY KEY (Codigo, Correlativo))"
        db.Execute cSql$
    
        ' Tabla Ratios
        cSql$ = "CREATE TABLE ratios (" & _
                "Codigo TEXT (3) CONSTRAINT [Primary Key] PRIMARY KEY, " & _
                "Descripcion TEXT (30))"
        db.Execute cSql$
    
        ' Tabla Resultados por Ratios
        cSql$ = "CREATE TABLE resultratios (" & _
                "Periodo TEXT (6), " & _
                "Codigo TEXT (3), " & _
                "Monto DOUBLE, " & _
                "CONSTRAINT [Primary Key] PRIMARY KEY (Periodo, Codigo))"
        db.Execute cSql$
    
    End If

    ' Creo los Periodos
'    For i% = 0 To 15
'        ' Creo los Arreglos para la Grabacion
'        aCampos = Array("ccb03cod", "ccb03des", "ccb03proc")
'        aValores = Array(cEjercicio$ & StrZero(i%, 2), NombreMes(i%) & " " & cEjercicio$, True)
'        aTipos = Array("C", "C", "L")
'        Call NuevoRegistro(db, "ccb03per", aCampos, aValores, aTipos)
'    Next i%
    
    ' Cierro la Base de Datos
    db.Close
    Call PunteroNormal

End Sub
Public Sub CambiaEjercicio(cRuta$, cBD$, cEjercicio$)

'    Dim db As Database, rs As Recordset
'
'    Call PunteroRelojDeArena
'
'    ' Abro la BD de la Empresa
'    Set db = DBEngine.Workspaces(0).OpenDatabase("", False, False, "odbc;dsn=" & cBD$ & ";uid=sa;pwd=;logintimeout=300;database=" & cBD$)
'
'    ' Verifico si existen los Periodos del Ejercicio
'    Set rs = AbreTabla(db, "SELECT ccb03cod FROM ccb03per WHERE Left(ccb03cod,4)='" & cEjercicio$ & "'", "", dbOpenSnapshot, dbReadOnly)
'    If rs.RecordCount > 0 Then rs.Close: db.Close: Call PunteroNormal: Exit Sub
'    rs.Close
'
'    ' Creo los Periodos
'    For i% = 0 To 15
'        ' Creo los Arreglos para la Grabacion
'        aCampos = Array("ccb03cod", "ccb03des", "ccb03proc", "ccb03conc")
'        aValores = Array(cEjercicio$ & StrZero(i%, 2), NombreMes(i%) & " " & cEjercicio$, True, False)
'        aTipos = Array("C", "C", "L", "L")
'        Call NuevoRegistro(db, "ccb03per", aCampos, aValores, aTipos)
'    Next i%
'
'    ' Si se esta utilizando SQL
'    If gbTipoBD$ = "SQL" Then
'        ' Inserto Registros y Cierro la Base de Datos
'        db.Execute "INSERT INTO ccacta (ccm01ano,ccm01cta) SELECT '" & cEjercicio$ & "',ccm01cta FROM ccm01cta", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO ccdaju (ccm03ano,ccm03mes,ccm03tip,ccm03cod,ccm03ctadet) SELECT '" & cEjercicio$ & "',ccm03mes,ccm03tip,ccm03cod,ccm03ctadet " & _
'                   "FROM ccdaju WHERE ccm03ano='" & Trim$(Val(cEjercicio$) - 1) & "'", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO ccdcta (ccm01ano,ccm01cta) SELECT '" & cEjercicio$ & "',ccm01cta FROM ccm01cta", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO precta (ccm01ano,ccm01cta) SELECT '" & cEjercicio$ & "',ccm01cta FROM ccm01cta", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO ccdcge (ccm01ano,ccm01cg) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cg", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO precge (ccm01ano,ccm01cg) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cg", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO ccdcdi (ccm01ano,ccm01cd) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cd", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO precdi (ccm01ano,ccm01cd) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cd", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO ccdcco (ccm01ano,ccm01cc,ccm01cta) SELECT '" & cEjercicio$ & "',ccm01cc,ccm01cta FROM ccdcco WHERE ccm01ano='" & Trim$(Val(cEjercicio$) - 1) & "'", dbSQLPassThrough + dbFailOnError
'        db.Execute "INSERT INTO precco (ccm01ano,ccm01cc) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cc", dbSQLPassThrough + dbFailOnError
'        For i% = 0 To 12
'            db.Execute "INSERT INTO ccm03ini (ccm03tip,ccm03cod,ccm03per) SELECT ccm03tip,ccm03cod,'" & cEjercicio$ & StrZero(i%, 2) & "' FROM ccm03ini WHERE ccm03per='" & Trim$(Val(cEjercicio$) - 1) & StrZero(i%, 2) & "'", dbSQLPassThrough + dbFailOnError
'        Next i%
'    Else
'        ' Inserto Registros y Cierro la Base de Datos
'        db.Execute "INSERT INTO ccacta (ccm01ano,ccm01cta) SELECT '" & cEjercicio$ & "',ccm01cta FROM ccm01cta", dbFailOnError
'        db.Execute "INSERT INTO ccdaju (ccm03ano,ccm03mes,ccm03tip,ccm03cod,ccm03ctadet) SELECT '" & cEjercicio$ & "',ccm03mes,ccm03tip,ccm03cod,ccm03ctadet " & _
'                   "FROM ccdaju WHERE ccm03ano='" & Trim$(Val(cEjercicio$) - 1) & "'", dbFailOnError
'        db.Execute "INSERT INTO ccdcta (ccm01ano,ccm01cta) SELECT '" & cEjercicio$ & "',ccm01cta FROM ccm01cta", dbFailOnError
'        db.Execute "INSERT INTO precta (ccm01ano,ccm01cta) SELECT '" & cEjercicio$ & "',ccm01cta FROM ccm01cta", dbFailOnError
'        db.Execute "INSERT INTO ccdcge (ccm01ano,ccm01cg) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cg", dbFailOnError
'        db.Execute "INSERT INTO precge (ccm01ano,ccm01cg) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cg", dbFailOnError
'        db.Execute "INSERT INTO ccdcdi (ccm01ano,ccm01cd) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cd", dbFailOnError
'        db.Execute "INSERT INTO precdi (ccm01ano,ccm01cd) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cd", dbFailOnError
'        db.Execute "INSERT INTO ccdcco (ccm01ano,ccm01cc,ccm01cta) SELECT '" & cEjercicio$ & "',ccm01cc,ccm01cta FROM ccdcco WHERE ccm01ano='" & Trim$(Val(cEjercicio$) - 1) & "'", dbFailOnError
'        db.Execute "INSERT INTO precco (ccm01ano,ccm01cc) SELECT '" & cEjercicio$ & "',ccb02cod FROM ccb02cc", dbFailOnError
'        For i% = 0 To 12
'            db.Execute "INSERT INTO ccm03ini (ccm03tip,ccm03cod,ccm03per) SELECT ccm03tip,ccm03cod,'" & cEjercicio$ & StrZero(i%, 2) & "' FROM ccm03ini WHERE ccm03per='" & Trim$(Val(cEjercicio$) - 1) & StrZero(i%, 2) & "'", dbFailOnError
'        Next i%
'    End If
'
'    db.Close
'    Call PunteroNormal
              
End Sub
